﻿using System;
using System.IO;

namespace 字符串转义符
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("今天天气好晴朗\n处处好风光");
            Console.WriteLine("==========================");
            Console.WriteLine("今天天气好晴朗\t处处好风光");
            Console.WriteLine("==========================");
            Console.WriteLine("\"今天天气好晴朗\"\"处处好风光\"");
            Console.WriteLine("==========================");
            Console.WriteLine(@"今天天气好晴朗
            处处好风光");//@保留原格式输出
            Console.WriteLine("==========================");
            string userFile = Environment.GetEnvironmentVariable("USERPROFILE") + @"\Desktop\";
            string str = "今天天气好晴朗\r\n处处好风光";//\n只在控制台窗口有用 写入文本则没用
            //Windows要用/R/N 
            if (File.Exists(userFile + "new.txt"))
            {
                File.Delete(userFile + "new.txt");//如果存在删除
            }
            else
            {
               // File.Create(userFile + "new.txt");//如果不存在创建
                File.WriteAllText(userFile + "new.txt", str);
            }
            Console.ReadKey();
        }
    }
}
